<template>
	<view class="login-container">
		<bgImg imgUrl="../../static/login/topTitle.png"></bgImg>
		<loginBtn @selectIsLogin="handleLogin" v-if="!isLogin"></loginBtn>
		<signIn v-if="isLogin" :signAll = "signAll"></signIn>
	
	</view>
</template>

<script>
	import signAll from "../../api/signAll.js"
	import common from "@/utils/common.js"
	import { Cookie } from "@/utils/cookie.js";
	export default {
		created() {
		
		
		
		},
		data() {
			return {
				// 是否授权登录
				isLogin:false,
				// 所有签到人数
				signAll:0
			}
		},
		async onLoad(options){
			// console.log(1)
			// const a = 1
			// console.log(a === 1)
			uni.getStorage({
			    key: 'isLogin',
			    success: function (res) {
			        // console.log(res.data);
					uni.redirectTo({
						url:"/pages/home/home"
					})
			    }
			});
			
			uni.getStorage({
			    key: 'userInfo',
			    fail:() => {
					this.isLogin = false
				},
				success:() => {
					this.isLogin = true
				}
			});
			
			


			
		},
		methods: {
			// 授权登录
			handleLogin(){
				this.isLogin = true;
				
				// 获取签到人数
				signAll().then(r => {
					this.signAll = r.data.data
				})
				
				uni.setStorage({
					key:"userInfo",
					data:{
						avatarUrl: "https://thirdwx.qlogo.cn/mmopen/vi_32/ruulJDWdVaGdqUjnia7bodZvz8icLXrSXeaJgdp8zicKeMeUPVh7dkzyH3WwkycX1j26G6AkafY9XYmZ6xAm8icVxA/132",
						city: "",
						country: "",
						gender: 0,
						language: "zh_CN",
						nickName: "发发",
						province: "",
					},
				})
				
				
				
		
				
			}
		}
	}
</script>

<style scoped lang="scss">
	.login-container{
		position: relative;
	}
</style>
